import __init__

class SimpleDatagram:
    
    """ 
        General datagram
    """
    
    def __init__(self,time,layer,ip_origin,port_origin,ip_dst,port_dst):
        self.time = time
        self.layer = layer
        self.ip_origin = ip_origin
        self.ip_dst = ip_dst
        self.port_origin = port_origin
        self.port_dst = port_dst
    
    def isBroadCastIPV4(self):
        """
            Verify if the packet is a broadcast packet 
        """
        data = self.ip_dst.split(".")
#        data = re.split(":", string, maxsplit)data[len(data)-2][0]
        if self.layer == "IP":
            if int(data[len(data)-1]) == 255:
                return True
        return False
            
        

class IPDatagram(SimpleDatagram):
    
    def __init__(self,time,layer,ip_origin,port_origin,ip_dst,port_dst,transport):
        self.time = time
        self.layer = layer
        self.ip_origin = ip_origin
        self.ip_dst = ip_dst
        self.port_origin = port_origin
        self.port_dst = port_dst
        self.transport = transport